package com.server.controller.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import io.swagger.annotations.Api;
import com.server.util.Result;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import com.server.entity.UcenterShopUser;
import com.server.service.IUcenterShopUserService;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.server.util.BaseController;

/**
 * <p>
 * 商家用户 控制器
 * </p>
 *
 * @author
 * @since 2020-04-03
 */
@RestController
@Controller
@AllArgsConstructor
@Slf4j
@Api(value = "商家用户管理", tags = "商家用户管理")
@RequestMapping("/admin/shopUser")
public class AdminUcenterShopUserController extends BaseController {

	private IUcenterShopUserService ucenterShopUserService;


	/**
     * 查询列表
     *
     * @author
     * @Date 2020-04-03
     */
	@GetMapping("/getListPage")
	@ApiOperation(value = "查询列表")
    @ResponseBody
    public Result<List<UcenterShopUser>> listPage(@ApiParam(name = "curPage", value = "当前页（不传入则默认1）", required = false)@RequestParam(required = false,defaultValue = "1") long curPage,
									@ApiParam(name = "pageSize", value = "当前页大小（不传入则默认10）", required = false)@RequestParam(required = false,defaultValue = "10") long pageSize) {
		Page<UcenterShopUser> page = new Page<>(curPage,pageSize);
        return ucenterShopUserService.findPage(page);
    }

    /**
     * 根据id查询详情
     *
     * @author
     * @Date 2020-04-03
     */
    @GetMapping("/findById")
	@ApiOperation(value = "根据id查询详情")
    @ResponseBody
    public Result<UcenterShopUser> findById(@ApiParam(name = "id", value = "商家用户id", required = true) @RequestParam String id) {
        return Result.returnData(ucenterShopUserService.findById(id));
    }

	 /**
     * 新增
     *
     * @author
     * @Date 2020-04-03
     */
	@PostMapping("/add")
    @ApiOperation(value = "新增")
    @ResponseBody
    public Result add(@ApiParam(name = "entity", value = "新增对象")@Valid @RequestBody UcenterShopUser entity) {

        return ucenterShopUserService.add(entity);
    }

	/**
     * 修改
     *
     * @author
     * @Date 2020-04-03
     */
	@PostMapping("/update")
    @ApiOperation(value = "修改")
    @ResponseBody
    public Result update(@ApiParam(name = "entity", value = "修改对象")@Valid @RequestBody UcenterShopUser entity) {

        return  ucenterShopUserService.update(entity);
    }

    /**
     * 批量删除
     *
     * @author
     * @Date 2020-04-03
     */
    @DeleteMapping("/del")
	@ApiOperation(value = "批量删除")
    @ResponseBody
    public Result delete(@ApiParam(name = "ids", value = "批量删除", required = true)@Valid @RequestParam String ids) {
        return ucenterShopUserService.delete(ids)?Result.ok("操作成功"):Result.error("操作失败");
    }

}
